package cn.fzkj.springcloud.controller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HystrixController {

//    @HystrixCommand(fallbackMethod = "getHandler") // 在出现异常的时候指定处理方法，即服务降级
    @GetMapping(value = "/payment/get/{id}")
    public String get(@PathVariable("id") Long id){
//        int a = 10/0;
        return "hystrix -> " + id;
    }

    // 处理服务降级
    private String getHandler(Long id){
        return "降级处理 -> " + id;
    }

}
